package com.bawei.park2211a.adapter

import android.graphics.Color
import android.widget.TextView
import androidx.cardview.widget.CardView
import com.bawei.base.bean.PollingEntity
import com.bawei.park2211a.R
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder

class PollingAdapter:BaseQuickAdapter<PollingEntity,BaseViewHolder>(R.layout.item_polling) {
    var area="东区"
    var status="进行中"
    override fun convert(helper: BaseViewHolder, item: PollingEntity) {
        helper.setText(R.id.polling_name,item.patrolPerson)
        helper.setText(R.id.polling_time,item.patrolTime)
        val polling_statu_background = helper.getView<CardView>(R.id.polling_statu_background)
        val polling_statu = helper.getView<TextView>(R.id.polling_statu)
        polling_statu.setTextColor(Color.WHITE)
        when(item.patrolPoints[0]){
            6->{area="科技园区——东区写字楼A01单元" }
            7->{area="科技园区——西区员工生活区"}
            8->{area="科技园区——南区科技研发中心"}
            9->{area="科技园区——北区董事办公处"}
            10->{area="科技园区——中央区域 中央机房"}
        }
        helper.setText(R.id.polling_area,area)
        when(item.patrolStatus){
            "0"->{
                polling_statu_background.setBackgroundResource(R.drawable.text_color3)
                polling_statu.setTextColor(Color.YELLOW)
                polling_statu.text="未巡检"

            }
            "1"->{
                polling_statu_background.setBackgroundResource(R.drawable.text_color2)
                polling_statu.setTextColor(Color.WHITE)
                polling_statu.text="进行中"
            }
            "2"->{
                polling_statu_background.setBackgroundResource(R.drawable.text_color1)
                polling_statu.setTextColor(Color.GREEN)
                polling_statu.text="已完成"
            }
            "3"->{
                polling_statu_background.setBackgroundResource(R.drawable.text_color6)
                polling_statu.setTextColor(Color.WHITE)
                polling_statu.text="已作废"
            }
        }
    }
}